#define _CRT_SECURE_NO_WARNINGS 1

#include"HashTable.h"
namespace wjx {
	template<class K,class V, class Hash = HashFunc<K>>
	class unorderedMap {
public:

		struct MapKeyofT {
			const K& operator()(const pair<const K,V>& kv) {
				return kv.first;
			}
		};

		typedef pair<K, V> T;

		typedef typename  wjx::HashTable<K, pair<const K, V>, MapKeyofT, Hash>::Iterator iterator;
		typedef typename wjx::HashTable<K, pair<const K, V>, MapKeyofT, Hash>::ConstIterator const_iterator;

		iterator begin()
		{
			return _ht.Begin();
		}
		iterator end()
		{
			return _ht.End();
		}
		const_iterator begin()const
		{
			return _ht.Begin();
		}
		const_iterator end()const
		{
			return _ht.End();
		}

		pair<iterator, bool> Insert(const T& kv) {
			return _ht.Insert(kv);
		}

		V& operator[](const K& key)
		{
			pair<iterator, bool> ret = _ht.Insert(make_pair(key, V()));
			return ret.first->second;
			//return ret.first._node->_data.second;

		}

		pair<iterator, bool> Find(const K& k) {
			return _ht.Find(k);
		}

		bool Erase(const K& k) {
			return _ht.Erase(k);
		}
		wjx::HashTable<K, pair<const K, V>, MapKeyofT,Hash> _ht;
	};
}